home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / overview / dtscpluslibrary / sources / processtest.cp < prev    next >
Encoding:
Text File  |  2000-06-23  |  2.5 KB  |  76 lines

  1. /*
  2.     File:        ProcessTest.cp
  3.  
  4.     Contains:    TProcess is a Process Manager class.
  5.                   ProcessTest.cp contains the testing code for testing TProcess.
  6.  
  7.     Written by: Kent Sandvik    
  8.  
  9.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24.  
  25. // Include files
  26. #ifndef _PROCESS_
  27. #include "Process.h"
  28. #endif
  29.  
  30.  
  31. // This test program will first create a TProcess object that will probe the current process
  32. // itself. The second test will iterate through processes in the list and print out information.
  33. // The final test will find the Finder Process ('MACS').
  34.  
  35.  
  36. void main(void)
  37. {
  38.     cout << "Start TProcess testing…\n";
  39.  
  40.     // create default TProcess
  41.     TProcess myProcess;
  42.  
  43.     cout << "First test, the current process\n";
  44.     cout << "We have just now " << myProcess.GetNumProcesses() << " processes running.\n";
  45.     cout << "This process has " << myProcess.GetFreeMem() << " memory free.\n";
  46.  
  47.     cout << "\nSecond test, iteration of processes…\n";
  48.  
  49.     for (TProcess procs; !procs.Last(); procs.Next())
  50.     {
  51.         ProcessSerialNumber thePSN = procs.GetProcessID();
  52.         cout << "High Process ID = " << thePSN.highLongOfPSN << "\n";
  53.         cout << "Low Process ID = " << thePSN.lowLongOfPSN << "\n";
  54.  
  55.         cout << "Process size (bytes) = " << procs.GetProcessSize() << "\n";
  56.         cout << "Free memory (bytes) = " << procs.GetFreeMem() << "\n";
  57.         cout << "Launch date (seconds) = " << procs.GetLaunchDate() << "\n";
  58.     }
  59.  
  60.     cout << "\nFinal test, try to find a process with signature 'MACS' (Finder)\n ";
  61.     TProcess findProc;
  62.     if (findProc.FindProcess('MACS'))
  63.         cout << " Finder Process found!\n";
  64.  
  65.     cout << "\nEnd TProcess testing!\n";
  66. }
  67.  
  68.  
  69. // _________________________________________________________________________________________________________ //
  70.  
  71. /*    Change History (most recent last):
  72.   No        Init.    Date        Comment
  73.   1            khs        6/10/92        New file
  74.   2            khs        7/6/92        First decent working class
  75. */
  76.